package org.hegang.design.first.singletonpattern;

/**
 * @ClassName SingletonObject
 * @Describe: 单例模式
 * @Author: gang.he
 * @Email: SmileSkylife@outlook.com
 * @Date: Created in 10:28 2019/6/30
 * @Modified_By: TODO
 * @Version: V1.0
 */
public class SingletonObject {
    /**
     * 自身创建，并私有化
     */
    private static SingletonObject instance = new SingletonObject();

    /**
     * 构造函数私有化，不能有其它途径创建，只能自身创建
     */
    private SingletonObject(){}

    /**
     * 获取该对象的唯一途径，因此static修饰
     * @return
     */
    public static SingletonObject getInstance(){
        return instance;
    }

    public void showMessage(){
        System.out.println("Hello World, I am SingletonPattern's Object.");
    }
}
